#!bin/bash


if [ -n "$1" ] ; then
  data_date=$1
else
  data_date=`date -d '-1 days' +%F`
fi


ODS_USER_ACTION_LOG_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/wyy_music_warehouse/user_action_log/${data_date}'
    OVERWRITE INTO TABLE wyy_music_warehouse.ods_user_action_log PARTITION (dt='${data_date}')
;
"


ODS_USER_INFO_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/wyy_music_warehouse/user_info/${data_date}'
    OVERWRITE INTO TABLE wyy_music_warehouse.ods_user_info PARTITION (dt='${data_date}')
;
"

ODS_MUSIC_INFO_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/wyy_music_warehouse/music_info/${data_date}'
    OVERWRITE INTO TABLE wyy_music_warehouse.ods_music_info PARTITION (dt='${data_date}')
;
"

ODS_ARTIST_INFO_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/wyy_music_warehouse/artist_info/${data_date}'
    OVERWRITE INTO TABLE wyy_music_warehouse.ods_artist_info PARTITION (dt='${data_date}')
;
"

ODS_ALBUM_INFO_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/wyy_music_warehouse/album_info/${data_date}'
    OVERWRITE INTO TABLE wyy_music_warehouse.ods_album_info PARTITION (dt='${data_date}')
;
"

ODS_DEVICE_INFO_SQL="
LOAD DATA INPATH '/warehouse/ads_basic/wyy_music_warehouse/device_info/${data_date}'
    OVERWRITE INTO TABLE wyy_music_warehouse.ods_device_info PARTITION (dt='${data_date}')
;
"


/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -p 123456 -e "${ODS_USER_ACTION_LOG_SQL}${ODS_USER_INFO_SQL}${ODS_MUSIC_INFO_SQL}${ODS_ARTIST_INFO_SQL}${ODS_ALBUM_INFO_SQL}${ODS_DEVICE_INFO_SQL}"

